package com.async.designpatterns.create.afactory;

import com.async.designpatterns.create.factory.MailSender;
import com.async.designpatterns.create.factory.Sender;

/**
 * Created by wenzhuo on 2018/1/1.
 */
public class MailSenderFactory implements Provider {

    @Override
    public Sender produce() {
        System.out.println("实时创建Mail Sender");
        return new MailSender();
    }

    @Override
    public Sender delayProduce(){
        try{
            System.out.println("创建Mail Sender");
            Thread.sleep(2000);
            System.out.println("创建Mail Sender完成！");
        } catch (Exception ex){
            return null;
        }
        return new MailSender();
    }
}
